package com.liu.goods.config;


import com.liu.shop.common.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {


    // 1、创建交换机
    @Bean
    public TopicExchange goodsExchange(){
        return new TopicExchange(RabbitConstant.GOODS_EXCHANGE,true,false);
    }

    // 2.队列
    @Bean
    public Queue goodsToesQueue(){
        return new Queue(RabbitConstant.GOODS_TOES_QUEUE,true,false,false,null);
    }

    // 3.绑定
    @Bean
    public Binding bindQueue(){
        return BindingBuilder.bind(goodsToesQueue()).to(goodsExchange()).with(RabbitConstant.ROUTE);
    }
}
